﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Design
{
    class CHtmlParsing
    {
        static CHtmlParsing insHtmlParsing = null;

        private CHtmlParsing()
        {
        }

        public static CHtmlParsing GetInstance()
        {
            if (null == insHtmlParsing)
            {
                insHtmlParsing = new CHtmlParsing();
            }

            return insHtmlParsing;
        }

        public ErrorCode ParsingToHtml(ElementType eleType, string strId, ref string sHtml, string strTxt)
        {
            string strHtml = "";
            ErrorCode errCode = ErrorCode.ERR_OK;

            switch (eleType)
            {
                case ElementType.ELE_TEXTBOX:
                {
                    strHtml = string.Format("<input type=\"TextBox\" ID=\"{0}\" />",
                        strId);

                    break;
                }
                case ElementType.ELE_COMBBOX:
                {
                    strHtml = string.Format("<input type=\"TextBox\" ID=\"{0}\" />",
                        strId);

                    break;
                }
                case ElementType.ELE_LABEL:
                {
                    strHtml = string.Format("<font type=\"Label\" ID=\"{0}\" color=\"#000000\"/>{1}</font>",
                        strId, strTxt);

                    break;
                }
                default:
                {
                    errCode = ErrorCode.ELEMENT_TYPE_UNKNOW;
                    break;
                }
            }

            sHtml = strHtml;

            return errCode;
        }
    }
}
